home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 2: Applications / Linux Cubed Series 2 - Applications.iso / editors / emacs / xemacs / xemacs-1.006 / xemacs-1 / lib / xemacs-19.13 / info / lispref.info-2 < prev    next >
Encoding:
GNU Info File  |  1995-09-01  |  47.0 KB  |  1,036 lines

  1. This is Info file ../../info/lispref.info, produced by Makeinfo-1.63
  2. from the input file lispref.texi.
  3.  
  4.    Edition History:
  5.  
  6.    GNU Emacs Lisp Reference Manual Second Edition (v2.01), May 1993 GNU
  7. Emacs Lisp Reference Manual Further Revised (v2.02), August 1993 Lucid
  8. Emacs Lisp Reference Manual (for 19.10) First Edition, March 1994
  9. XEmacs Lisp Programmer's Manual (for 19.12) Second Edition, April 1995
  10. GNU Emacs Lisp Reference Manual v2.4, June 1995 XEmacs Lisp
  11. Programmer's Manual (for 19.13) Third Edition, July 1995
  12.  
  13.    Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995 Free Software
  14. Foundation, Inc.  Copyright (C) 1994, 1995 Sun Microsystems, Inc.
  15. Copyright (C) 1995 Amdahl Corporation.  Copyright (C) 1995 Ben Wing.
  16.  
  17.    Permission is granted to make and distribute verbatim copies of this
  18. manual provided the copyright notice and this permission notice are
  19. preserved on all copies.
  20.  
  21.    Permission is granted to copy and distribute modified versions of
  22. this manual under the conditions for verbatim copying, provided that the
  23. entire resulting derived work is distributed under the terms of a
  24. permission notice identical to this one.
  25.  
  26.    Permission is granted to copy and distribute translations of this
  27. manual into another language, under the above conditions for modified
  28. versions, except that this permission notice may be stated in a
  29. translation approved by the Foundation.
  30.  
  31.    Permission is granted to copy and distribute modified versions of
  32. this manual under the conditions for verbatim copying, provided also
  33. that the section entitled "GNU General Public License" is included
  34. exactly as in the original, and provided that the entire resulting
  35. derived work is distributed under the terms of a permission notice
  36. identical to this one.
  37.  
  38.    Permission is granted to copy and distribute translations of this
  39. manual into another language, under the above conditions for modified
  40. versions, except that the section entitled "GNU General Public License"
  41. may be included in a translation approved by the Free Software
  42. Foundation instead of in the original English.
  43.  
  44. 
  45. File: lispref.info,  Node: Copying,  Next: Introduction,  Prev: Top,  Up: Top
  46.  
  47. GNU GENERAL PUBLIC LICENSE
  48. **************************
  49.  
  50.                          Version 2, June 1991
  51.  
  52.      Copyright (C) 1989, 1991 Free Software Foundation, Inc.
  53.      675 Mass Ave, Cambridge, MA 02139, USA
  54.      
  55.      Everyone is permitted to copy and distribute verbatim copies
  56.      of this license document, but changing it is not allowed.
  57.  
  58. Preamble
  59. ========
  60.  
  61.    The licenses for most software are designed to take away your
  62. freedom to share and change it.  By contrast, the GNU General Public
  63. License is intended to guarantee your freedom to share and change free
  64. software--to make sure the software is free for all its users.  This
  65. General Public License applies to most of the Free Software
  66. Foundation's software and to any other program whose authors commit to
  67. using it.  (Some other Free Software Foundation software is covered by
  68. the GNU Library General Public License instead.)  You can apply it to
  69. your programs, too.
  70.  
  71.    When we speak of free software, we are referring to freedom, not
  72. price.  Our General Public Licenses are designed to make sure that you
  73. have the freedom to distribute copies of free software (and charge for
  74. this service if you wish), that you receive source code or can get it
  75. if you want it, that you can change the software or use pieces of it in
  76. new free programs; and that you know you can do these things.
  77.  
  78.    To protect your rights, we need to make restrictions that forbid
  79. anyone to deny you these rights or to ask you to surrender the rights.
  80. These restrictions translate to certain responsibilities for you if you
  81. distribute copies of the software, or if you modify it.
  82.  
  83.    For example, if you distribute copies of such a program, whether
  84. gratis or for a fee, you must give the recipients all the rights that
  85. you have.  You must make sure that they, too, receive or can get the
  86. source code.  And you must show them these terms so they know their
  87. rights.
  88.  
  89.    We protect your rights with two steps: (1) copyright the software,
  90. and (2) offer you this license which gives you legal permission to copy,
  91. distribute and/or modify the software.
  92.  
  93.    Also, for each author's protection and ours, we want to make certain
  94. that everyone understands that there is no warranty for this free
  95. software.  If the software is modified by someone else and passed on, we
  96. want its recipients to know that what they have is not the original, so
  97. that any problems introduced by others will not reflect on the original
  98. authors' reputations.
  99.  
  100.    Finally, any free program is threatened constantly by software
  101. patents.  We wish to avoid the danger that redistributors of a free
  102. program will individually obtain patent licenses, in effect making the
  103. program proprietary.  To prevent this, we have made it clear that any
  104. patent must be licensed for everyone's free use or not licensed at all.
  105.  
  106.    The precise terms and conditions for copying, distribution and
  107. modification follow.
  108.  
  109.     TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
  110.  
  111.   0. This License applies to any program or other work which contains a
  112.      notice placed by the copyright holder saying it may be distributed
  113.      under the terms of this General Public License.  The "Program",
  114.      below, refers to any such program or work, and a "work based on
  115.      the Program" means either the Program or any derivative work under
  116.      copyright law: that is to say, a work containing the Program or a
  117.      portion of it, either verbatim or with modifications and/or
  118.      translated into another language.  (Hereinafter, translation is
  119.      included without limitation in the term "modification".)  Each
  120.      licensee is addressed as "you".
  121.  
  122.      Activities other than copying, distribution and modification are
  123.      not covered by this License; they are outside its scope.  The act
  124.      of running the Program is not restricted, and the output from the
  125.      Program is covered only if its contents constitute a work based on
  126.      the Program (independent of having been made by running the
  127.      Program).  Whether that is true depends on what the Program does.
  128.  
  129.   1. You may copy and distribute verbatim copies of the Program's
  130.      source code as you receive it, in any medium, provided that you
  131.      conspicuously and appropriately publish on each copy an appropriate
  132.      copyright notice and disclaimer of warranty; keep intact all the
  133.      notices that refer to this License and to the absence of any
  134.      warranty; and give any other recipients of the Program a copy of
  135.      this License along with the Program.
  136.  
  137.      You may charge a fee for the physical act of transferring a copy,
  138.      and you may at your option offer warranty protection in exchange
  139.      for a fee.
  140.  
  141.   2. You may modify your copy or copies of the Program or any portion
  142.      of it, thus forming a work based on the Program, and copy and
  143.      distribute such modifications or work under the terms of Section 1
  144.      above, provided that you also meet all of these conditions:
  145.  
  146.        a. You must cause the modified files to carry prominent notices
  147.           stating that you changed the files and the date of any change.
  148.  
  149.        b. You must cause any work that you distribute or publish, that
  150.           in whole or in part contains or is derived from the Program
  151.           or any part thereof, to be licensed as a whole at no charge
  152.           to all third parties under the terms of this License.
  153.  
  154.        c. If the modified program normally reads commands interactively
  155.           when run, you must cause it, when started running for such
  156.           interactive use in the most ordinary way, to print or display
  157.           an announcement including an appropriate copyright notice and
  158.           a notice that there is no warranty (or else, saying that you
  159.           provide a warranty) and that users may redistribute the
  160.           program under these conditions, and telling the user how to
  161.           view a copy of this License.  (Exception: if the Program
  162.           itself is interactive but does not normally print such an
  163.           announcement, your work based on the Program is not required
  164.           to print an announcement.)
  165.  
  166.      These requirements apply to the modified work as a whole.  If
  167.      identifiable sections of that work are not derived from the
  168.      Program, and can be reasonably considered independent and separate
  169.      works in themselves, then this License, and its terms, do not
  170.      apply to those sections when you distribute them as separate
  171.      works.  But when you distribute the same sections as part of a
  172.      whole which is a work based on the Program, the distribution of
  173.      the whole must be on the terms of this License, whose permissions
  174.      for other licensees extend to the entire whole, and thus to each
  175.      and every part regardless of who wrote it.
  176.  
  177.      Thus, it is not the intent of this section to claim rights or
  178.      contest your rights to work written entirely by you; rather, the
  179.      intent is to exercise the right to control the distribution of
  180.      derivative or collective works based on the Program.
  181.  
  182.      In addition, mere aggregation of another work not based on the
  183.      Program with the Program (or with a work based on the Program) on
  184.      a volume of a storage or distribution medium does not bring the
  185.      other work under the scope of this License.
  186.  
  187.   3. You may copy and distribute the Program (or a work based on it,
  188.      under Section 2) in object code or executable form under the terms
  189.      of Sections 1 and 2 above provided that you also do one of the
  190.      following:
  191.  
  192.        a. Accompany it with the complete corresponding machine-readable
  193.           source code, which must be distributed under the terms of
  194.           Sections 1 and 2 above on a medium customarily used for
  195.           software interchange; or,
  196.  
  197.        b. Accompany it with a written offer, valid for at least three
  198.           years, to give any third party, for a charge no more than your
  199.           cost of physically performing source distribution, a complete
  200.           machine-readable copy of the corresponding source code, to be
  201.           distributed under the terms of Sections 1 and 2 above on a
  202.           medium customarily used for software interchange; or,
  203.  
  204.        c. Accompany it with the information you received as to the offer
  205.           to distribute corresponding source code.  (This alternative is
  206.           allowed only for noncommercial distribution and only if you
  207.           received the program in object code or executable form with
  208.           such an offer, in accord with Subsection b above.)
  209.  
  210.      The source code for a work means the preferred form of the work for
  211.      making modifications to it.  For an executable work, complete
  212.      source code means all the source code for all modules it contains,
  213.      plus any associated interface definition files, plus the scripts
  214.      used to control compilation and installation of the executable.
  215.      However, as a special exception, the source code distributed need
  216.      not include anything that is normally distributed (in either
  217.      source or binary form) with the major components (compiler,
  218.      kernel, and so on) of the operating system on which the executable
  219.      runs, unless that component itself accompanies the executable.
  220.  
  221.      If distribution of executable or object code is made by offering
  222.      access to copy from a designated place, then offering equivalent
  223.      access to copy the source code from the same place counts as
  224.      distribution of the source code, even though third parties are not
  225.      compelled to copy the source along with the object code.
  226.  
  227.   4. You may not copy, modify, sublicense, or distribute the Program
  228.      except as expressly provided under this License.  Any attempt
  229.      otherwise to copy, modify, sublicense or distribute the Program is
  230.      void, and will automatically terminate your rights under this
  231.      License.  However, parties who have received copies, or rights,
  232.      from you under this License will not have their licenses
  233.      terminated so long as such parties remain in full compliance.
  234.  
  235.   5. You are not required to accept this License, since you have not
  236.      signed it.  However, nothing else grants you permission to modify
  237.      or distribute the Program or its derivative works.  These actions
  238.      are prohibited by law if you do not accept this License.
  239.      Therefore, by modifying or distributing the Program (or any work
  240.      based on the Program), you indicate your acceptance of this
  241.      License to do so, and all its terms and conditions for copying,
  242.      distributing or modifying the Program or works based on it.
  243.  
  244.   6. Each time you redistribute the Program (or any work based on the
  245.      Program), the recipient automatically receives a license from the
  246.      original licensor to copy, distribute or modify the Program
  247.      subject to these terms and conditions.  You may not impose any
  248.      further restrictions on the recipients' exercise of the rights
  249.      granted herein.  You are not responsible for enforcing compliance
  250.      by third parties to this License.
  251.  
  252.   7. If, as a consequence of a court judgment or allegation of patent
  253.      infringement or for any other reason (not limited to patent
  254.      issues), conditions are imposed on you (whether by court order,
  255.      agreement or otherwise) that contradict the conditions of this
  256.      License, they do not excuse you from the conditions of this
  257.      License.  If you cannot distribute so as to satisfy simultaneously
  258.      your obligations under this License and any other pertinent
  259.      obligations, then as a consequence you may not distribute the
  260.      Program at all.  For example, if a patent license would not permit
  261.      royalty-free redistribution of the Program by all those who
  262.      receive copies directly or indirectly through you, then the only
  263.      way you could satisfy both it and this License would be to refrain
  264.      entirely from distribution of the Program.
  265.  
  266.      If any portion of this section is held invalid or unenforceable
  267.      under any particular circumstance, the balance of the section is
  268.      intended to apply and the section as a whole is intended to apply
  269.      in other circumstances.
  270.  
  271.      It is not the purpose of this section to induce you to infringe any
  272.      patents or other property right claims or to contest validity of
  273.      any such claims; this section has the sole purpose of protecting
  274.      the integrity of the free software distribution system, which is
  275.      implemented by public license practices.  Many people have made
  276.      generous contributions to the wide range of software distributed
  277.      through that system in reliance on consistent application of that
  278.      system; it is up to the author/donor to decide if he or she is
  279.      willing to distribute software through any other system and a
  280.      licensee cannot impose that choice.
  281.  
  282.      This section is intended to make thoroughly clear what is believed
  283.      to be a consequence of the rest of this License.
  284.  
  285.   8. If the distribution and/or use of the Program is restricted in
  286.      certain countries either by patents or by copyrighted interfaces,
  287.      the original copyright holder who places the Program under this
  288.      License may add an explicit geographical distribution limitation
  289.      excluding those countries, so that distribution is permitted only
  290.      in or among countries not thus excluded.  In such case, this
  291.      License incorporates the limitation as if written in the body of
  292.      this License.
  293.  
  294.   9. The Free Software Foundation may publish revised and/or new
  295.      versions of the General Public License from time to time.  Such
  296.      new versions will be similar in spirit to the present version, but
  297.      may differ in detail to address new problems or concerns.
  298.  
  299.      Each version is given a distinguishing version number.  If the
  300.      Program specifies a version number of this License which applies
  301.      to it and "any later version", you have the option of following
  302.      the terms and conditions either of that version or of any later
  303.      version published by the Free Software Foundation.  If the Program
  304.      does not specify a version number of this License, you may choose
  305.      any version ever published by the Free Software Foundation.
  306.  
  307.  10. If you wish to incorporate parts of the Program into other free
  308.      programs whose distribution conditions are different, write to the
  309.      author to ask for permission.  For software which is copyrighted
  310.      by the Free Software Foundation, write to the Free Software
  311.      Foundation; we sometimes make exceptions for this.  Our decision
  312.      will be guided by the two goals of preserving the free status of
  313.      all derivatives of our free software and of promoting the sharing
  314.      and reuse of software generally.
  315.  
  316.                                 NO WARRANTY
  317.  
  318.  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO
  319.      WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE
  320.      LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
  321.      HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT
  322.      WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT
  323.      NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  324.      FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS TO THE
  325.      QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
  326.      PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY
  327.      SERVICING, REPAIR OR CORRECTION.
  328.  
  329.  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
  330.      WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY
  331.      MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE
  332.      LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL,
  333.      INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR
  334.      INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
  335.      DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU
  336.      OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY
  337.      OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN
  338.      ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
  339.  
  340.                       END OF TERMS AND CONDITIONS
  341.  
  342. How to Apply These Terms to Your New Programs
  343. =============================================
  344.  
  345.    If you develop a new program, and you want it to be of the greatest
  346. possible use to the public, the best way to achieve this is to make it
  347. free software which everyone can redistribute and change under these
  348. terms.
  349.  
  350.    To do so, attach the following notices to the program.  It is safest
  351. to attach them to the start of each source file to most effectively
  352. convey the exclusion of warranty; and each file should have at least
  353. the "copyright" line and a pointer to where the full notice is found.
  354.  
  355.      ONE LINE TO GIVE THE PROGRAM'S NAME AND AN IDEA OF WHAT IT DOES.
  356.      Copyright (C) 19YY  NAME OF AUTHOR
  357.      
  358.      This program is free software; you can redistribute it and/or
  359.      modify it under the terms of the GNU General Public License
  360.      as published by the Free Software Foundation; either version 2
  361.      of the License, or (at your option) any later version.
  362.      
  363.      This program is distributed in the hope that it will be useful,
  364.      but WITHOUT ANY WARRANTY; without even the implied warranty of
  365.      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  366.      GNU General Public License for more details.
  367.      
  368.      You should have received a copy of the GNU General Public License
  369.      along with this program; if not, write to the Free Software
  370.      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  371.  
  372.    Also add information on how to contact you by electronic and paper
  373. mail.
  374.  
  375.    If the program is interactive, make it output a short notice like
  376. this when it starts in an interactive mode:
  377.  
  378.      Gnomovision version 69, Copyright (C) 19YY NAME OF AUTHOR
  379.      Gnomovision comes with ABSOLUTELY NO WARRANTY; for details
  380.      type `show w'.  This is free software, and you are welcome
  381.      to redistribute it under certain conditions; type `show c'
  382.      for details.
  383.  
  384.    The hypothetical commands `show w' and `show c' should show the
  385. appropriate parts of the General Public License.  Of course, the
  386. commands you use may be called something other than `show w' and `show
  387. c'; they could even be mouse-clicks or menu items--whatever suits your
  388. program.
  389.  
  390.    You should also get your employer (if you work as a programmer) or
  391. your school, if any, to sign a "copyright disclaimer" for the program,
  392. if necessary.  Here is a sample; alter the names:
  393.  
  394.      Yoyodyne, Inc., hereby disclaims all copyright
  395.      interest in the program `Gnomovision'
  396.      (which makes passes at compilers) written
  397.      by James Hacker.
  398.      
  399.      SIGNATURE OF TY COON, 1 April 1989
  400.      Ty Coon, President of Vice
  401.  
  402.    This General Public License does not permit incorporating your
  403. program into proprietary programs.  If your program is a subroutine
  404. library, you may consider it more useful to permit linking proprietary
  405. applications with the library.  If this is what you want to do, use the
  406. GNU Library General Public License instead of this License.
  407.  
  408. 
  409. File: lispref.info,  Node: Introduction,  Next: Lisp Data Types,  Prev: Copying,  Up: Top
  410.  
  411. Introduction
  412. ************
  413.  
  414.    Most of the XEmacs text editor is written in the programming
  415. language called Emacs Lisp.  You can write new code in Emacs Lisp and
  416. install it as an extension to the editor.  However, Emacs Lisp is more
  417. than a mere "extension language"; it is a full computer programming
  418. language in its own right.  You can use it as you would any other
  419. programming language.
  420.  
  421.    Because Emacs Lisp is designed for use in an editor, it has special
  422. features for scanning and parsing text as well as features for handling
  423. files, buffers, displays, subprocesses, and so on.  Emacs Lisp is
  424. closely integrated with the editing facilities; thus, editing commands
  425. are functions that can also conveniently be called from Lisp programs,
  426. and parameters for customization are ordinary Lisp variables.
  427.  
  428.    This manual describes Emacs Lisp, presuming considerable familiarity
  429. with the use of XEmacs for editing.  (See `The XEmacs Reference
  430. Manual', for this basic information.)  Generally speaking, the earlier
  431. chapters describe features of Emacs Lisp that have counterparts in many
  432. programming languages, and later chapters describe features that are
  433. peculiar to Emacs Lisp or relate specifically to editing.
  434.  
  435.    This is edition 3.0.
  436.  
  437. * Menu:
  438.  
  439. * Caveats::             Flaws and a request for help.
  440. * Lisp History::        Emacs Lisp is descended from Maclisp.
  441. * Conventions::         How the manual is formatted.
  442. * Acknowledgements::    The authors, editors, and sponsors of this manual.
  443.  
  444. 
  445. File: lispref.info,  Node: Caveats,  Next: Lisp History,  Up: Introduction
  446.  
  447. Caveats
  448. =======
  449.  
  450.    This manual has gone through numerous drafts.  It is nearly complete
  451. but not flawless.  There are a few topics that are not covered, either
  452. because we consider them secondary (such as most of the individual
  453. modes) or because they are yet to be written.  Because we are not able
  454. to deal with them completely, we have left out several parts
  455. intentionally.  This includes most information about usage on VMS.
  456.  
  457.    The manual should be fully correct in what it does cover, and it is
  458. therefore open to criticism on anything it says--from specific examples
  459. and descriptive text, to the ordering of chapters and sections.  If
  460. something is confusing, or you find that you have to look at the sources
  461. or experiment to learn something not covered in the manual, then perhaps
  462. the manual should be fixed.  Please let us know.
  463.  
  464.    As you use this manual, we ask that you send corrections as soon as
  465. you find them.  If you think of a simple, real life example for a
  466. function or group of functions, please make an effort to write it up
  467. and send it in.  Please reference any comments to the node name and
  468. function or variable name, as appropriate.  Also state the number of
  469. the edition which you are criticizing.
  470.  
  471.    This manual was originally written for FSF Emacs 19 and was updated
  472. by Ben Wing (wing@netcom.com) for Lucid Emacs 19.10 and later for XEmacs
  473. 19.12 and XEmacs 19.13.  Please send comments and corrections relating
  474. to XEmacs-specific portions of this manual to
  475.      xemacs@cs.uiuc.edu
  476.  
  477.    or post to the newsgroup
  478.      comp.emacs.xemacs
  479.  
  480.       --Ben Wing
  481.  
  482. 
  483. File: lispref.info,  Node: Lisp History,  Next: Conventions,  Prev: Caveats,  Up: Introduction
  484.  
  485. Lisp History
  486. ============
  487.  
  488.    Lisp (LISt Processing language) was first developed in the late
  489. 1950's at the Massachusetts Institute of Technology for research in
  490. artificial intelligence.  The great power of the Lisp language makes it
  491. superior for other purposes as well, such as writing editing commands.
  492.  
  493.    Dozens of Lisp implementations have been built over the years, each
  494. with its own idiosyncrasies.  Many of them were inspired by Maclisp,
  495. which was written in the 1960's at MIT's Project MAC.  Eventually the
  496. implementors of the descendants of Maclisp came together and developed a
  497. standard for Lisp systems, called Common Lisp.
  498.  
  499.    Emacs Lisp is largely inspired by Maclisp, and a little by Common
  500. Lisp.  If you know Common Lisp, you will notice many similarities.
  501. However, many of the features of Common Lisp have been omitted or
  502. simplified in order to reduce the memory requirements of XEmacs.
  503. Sometimes the simplifications are so drastic that a Common Lisp user
  504. might be very confused.  We will occasionally point out how Emacs Lisp
  505. differs from Common Lisp.  If you don't know Common Lisp, don't worry
  506. about it; this manual is self-contained.
  507.  
  508. 
  509. File: lispref.info,  Node: Conventions,  Next: Acknowledgements,  Prev: Lisp History,  Up: Introduction
  510.  
  511. Conventions
  512. ===========
  513.  
  514.    This section explains the notational conventions that are used in
  515. this manual.  You may want to skip this section and refer back to it
  516. later.
  517.  
  518. * Menu:
  519.  
  520. * Some Terms::               Explanation of terms we use in this manual.
  521. * nil and t::                How the symbols `nil' and `t' are used.
  522. * Evaluation Notation::      The format we use for examples of evaluation.
  523. * Printing Notation::        The format we use for examples that print output.
  524. * Error Messages::           The format we use for examples of errors.
  525. * Buffer Text Notation::     The format we use for buffer contents in examples.
  526. * Format of Descriptions::   Notation for describing functions, variables, etc.
  527.  
  528. 
  529. File: lispref.info,  Node: Some Terms,  Next: nil and t,  Up: Conventions
  530.  
  531. Some Terms
  532. ----------
  533.  
  534.    Throughout this manual, the phrases "the Lisp reader" and "the Lisp
  535. printer" are used to refer to those routines in Lisp that convert
  536. textual representations of Lisp objects into actual Lisp objects, and
  537. vice versa.  *Note Printed Representation::, for more details.  You, the
  538. person reading this manual, are thought of as "the programmer" and are
  539. addressed as "you".  "The user" is the person who uses Lisp programs,
  540. including those you write.
  541.  
  542.    Examples of Lisp code appear in this font or form: `(list 1 2 3)'.
  543. Names that represent arguments or metasyntactic variables appear in
  544. this font or form: FIRST-NUMBER.
  545.  
  546. 
  547. File: lispref.info,  Node: nil and t,  Next: Evaluation Notation,  Prev: Some Terms,  Up: Conventions
  548.  
  549. `nil' and `t'
  550. -------------
  551.  
  552.    In Lisp, the symbol `nil' has three separate meanings: it is a
  553. symbol with the name `nil'; it is the logical truth value FALSE; and it
  554. is the empty list--the list of zero elements.  When used as a variable,
  555. `nil' always has the value `nil'.
  556.  
  557.    As far as the Lisp reader is concerned, `()' and `nil' are
  558. identical: they stand for the same object, the symbol `nil'.  The
  559. different ways of writing the symbol are intended entirely for human
  560. readers.  After the Lisp reader has read either `()' or `nil', there is
  561. no way to determine which representation was actually written by the
  562. programmer.
  563.  
  564.    In this manual, we use `()' when we wish to emphasize that it means
  565. the empty list, and we use `nil' when we wish to emphasize that it
  566. means the truth value FALSE.  That is a good convention to use in Lisp
  567. programs also.
  568.  
  569.      (cons 'foo ())                ; Emphasize the empty list
  570.      (not nil)                     ; Emphasize the truth value FALSE
  571.  
  572.    In contexts where a truth value is expected, any non-`nil' value is
  573. considered to be TRUE.  However, `t' is the preferred way to represent
  574. the truth value TRUE.  When you need to choose a value which represents
  575. TRUE, and there is no other basis for choosing, use `t'.  The symbol
  576. `t' always has value `t'.
  577.  
  578.    In Emacs Lisp, `nil' and `t' are special symbols that always
  579. evaluate to themselves.  This is so that you do not need to quote them
  580. to use them as constants in a program.  An attempt to change their
  581. values results in a `setting-constant' error.  *Note Accessing
  582. Variables::.
  583.  
  584. 
  585. File: lispref.info,  Node: Evaluation Notation,  Next: Printing Notation,  Prev: nil and t,  Up: Conventions
  586.  
  587. Evaluation Notation
  588. -------------------
  589.  
  590.    A Lisp expression that you can evaluate is called a "form".
  591. Evaluating a form always produces a result, which is a Lisp object.  In
  592. the examples in this manual, this is indicated with `=>':
  593.  
  594.      (car '(1 2))
  595.           => 1
  596.  
  597. You can read this as "`(car '(1 2))' evaluates to 1".
  598.  
  599.    When a form is a macro call, it expands into a new form for Lisp to
  600. evaluate.  We show the result of the expansion with `==>'.  We may or
  601. may not show the actual result of the evaluation of the expanded form.
  602.  
  603.      (third '(a b c))
  604.           ==> (car (cdr (cdr '(a b c))))
  605.           => c
  606.  
  607.    Sometimes to help describe one form we show another form that
  608. produces identical results.  The exact equivalence of two forms is
  609. indicated with `=='.
  610.  
  611.      (make-sparse-keymap) == (list 'keymap)
  612.  
  613. 
  614. File: lispref.info,  Node: Printing Notation,  Next: Error Messages,  Prev: Evaluation Notation,  Up: Conventions
  615.  
  616. Printing Notation
  617. -----------------
  618.  
  619.    Many of the examples in this manual print text when they are
  620. evaluated.  If you execute example code in a Lisp Interaction buffer
  621. (such as the buffer `*scratch*'), the printed text is inserted into the
  622. buffer.  If you execute the example by other means (such as by
  623. evaluating the function `eval-region'), the printed text is displayed
  624. in the echo area.  You should be aware that text displayed in the echo
  625. area is truncated to a single line.
  626.  
  627.    Examples in this manual indicate printed text with `-|',
  628. irrespective of where that text goes.  The value returned by evaluating
  629. the form (here `bar') follows on a separate line.
  630.  
  631.      (progn (print 'foo) (print 'bar))
  632.           -| foo
  633.           -| bar
  634.           => bar
  635.  
  636. 
  637. File: lispref.info,  Node: Error Messages,  Next: Buffer Text Notation,  Prev: Printing Notation,  Up: Conventions
  638.  
  639. Error Messages
  640. --------------
  641.  
  642.    Some examples signal errors.  This normally displays an error message
  643. in the echo area.  We show the error message on a line starting with
  644. `error-->'.  Note that `error-->' itself does not appear in the echo
  645. area.
  646.  
  647.      (+ 23 'x)
  648.      error--> Wrong type argument: integer-or-marker-p, x
  649.  
  650. 
  651. File: lispref.info,  Node: Buffer Text Notation,  Next: Format of Descriptions,  Prev: Error Messages,  Up: Conventions
  652.  
  653. Buffer Text Notation
  654. --------------------
  655.  
  656.    Some examples show modifications to text in a buffer, with "before"
  657. and "after" versions of the text.  These examples show the contents of
  658. the buffer in question between two lines of dashes containing the buffer
  659. name.  In addition, `-!-' indicates the location of point.  (The symbol
  660. for point, of course, is not part of the text in the buffer; it
  661. indicates the place *between* two characters where point is located.)
  662.  
  663.      ---------- Buffer: foo ----------
  664.      This is the -!-contents of foo.
  665.      ---------- Buffer: foo ----------
  666.      
  667.      (insert "changed ")
  668.           => nil
  669.      ---------- Buffer: foo ----------
  670.      This is the changed -!-contents of foo.
  671.      ---------- Buffer: foo ----------
  672.  
  673. 
  674. File: lispref.info,  Node: Format of Descriptions,  Prev: Buffer Text Notation,  Up: Conventions
  675.  
  676. Format of Descriptions
  677. ----------------------
  678.  
  679.    Functions, variables, macros, commands, user options, and special
  680. forms are described in this manual in a uniform format.  The first line
  681. of a description contains the name of the item followed by its
  682. arguments, if any.
  683.  
  684.    The category--function, variable, or whatever--appears at the
  685. beginning of the line.  The description follows on succeeding lines,
  686. sometimes with examples.
  687.  
  688. * Menu:
  689.  
  690. * A Sample Function Description::       A description of an imaginary
  691.                                           function, `foo'.
  692. * A Sample Variable Description::       A description of an imaginary
  693.                                           variable,
  694.                                           `electric-future-map'.
  695.  
  696. 
  697. File: lispref.info,  Node: A Sample Function Description,  Next: A Sample Variable Description,  Up: Format of Descriptions
  698.  
  699. A Sample Function Description
  700. .............................
  701.  
  702.    In a function description, the name of the function being described
  703. appears first.  It is followed on the same line by a list of parameters.
  704. The names used for the parameters are also used in the body of the
  705. description.
  706.  
  707.    The appearance of the keyword `&optional' in the parameter list
  708. indicates that the arguments for subsequent parameters may be omitted
  709. (omitted parameters default to `nil').  Do not write `&optional' when
  710. you call the function.
  711.  
  712.    The keyword `&rest' (which will always be followed by a single
  713. parameter) indicates that any number of arguments can follow.  The value
  714. of the single following parameter will be a list of all these arguments.
  715. Do not write `&rest' when you call the function.
  716.  
  717.    Here is a description of an imaginary function `foo':
  718.  
  719.  - Function: foo INTEGER1 &optional INTEGER2 &rest INTEGERS
  720.      The function `foo' subtracts INTEGER1 from INTEGER2, then adds all
  721.      the rest of the arguments to the result.  If INTEGER2 is not
  722.      supplied, then the number 19 is used by default.
  723.  
  724.           (foo 1 5 3 9)
  725.                => 16
  726.           (foo 5)
  727.                => 14
  728.  
  729.      More generally,
  730.  
  731.           (foo W X Y...)
  732.           ==
  733.           (+ (- X W) Y...)
  734.  
  735.    Any parameter whose name contains the name of a type (e.g., INTEGER,
  736. INTEGER1 or BUFFER) is expected to be of that type.  A plural of a type
  737. (such as BUFFERS) often means a list of objects of that type.
  738. Parameters named OBJECT may be of any type.  (*Note Lisp Data Types::,
  739. for a list of XEmacs object types.) Parameters with other sorts of
  740. names (e.g., NEW-FILE) are discussed specifically in the description of
  741. the function.  In some sections, features common to parameters of
  742. several functions are described at the beginning.
  743.  
  744.    *Note Lambda Expressions::, for a more complete description of
  745. optional and rest arguments.
  746.  
  747.    Command, macro, and special form descriptions have the same format,
  748. but the word `Function' is replaced by `Command', `Macro', or `Special
  749. Form', respectively.  Commands are simply functions that may be called
  750. interactively; macros process their arguments differently from functions
  751. (the arguments are not evaluated), but are presented the same way.
  752.  
  753.    Special form descriptions use a more complex notation to specify
  754. optional and repeated parameters because they can break the argument
  755. list down into separate arguments in more complicated ways.
  756. ``[OPTIONAL-ARG]'' means that OPTIONAL-ARG is optional and
  757. `REPEATED-ARGS...' stands for zero or more arguments.  Parentheses are
  758. used when several arguments are grouped into additional levels of list
  759. structure.  Here is an example:
  760.  
  761.  - Special Form: count-loop (VAR [FROM TO [INC]]) BODY...
  762.      This imaginary special form implements a loop that executes the
  763.      BODY forms and then increments the variable VAR on each iteration.
  764.      On the first iteration, the variable has the value FROM; on
  765.      subsequent iterations, it is incremented by 1 (or by INC if that
  766.      is given).  The loop exits before executing BODY if VAR equals TO.
  767.      Here is an example:
  768.  
  769.           (count-loop (i 0 10)
  770.             (prin1 i) (princ " ")
  771.             (prin1 (aref vector i)) (terpri))
  772.  
  773.      If FROM and TO are omitted, then VAR is bound to `nil' before the
  774.      loop begins, and the loop exits if VAR is non-`nil' at the
  775.      beginning of an iteration.  Here is an example:
  776.  
  777.           (count-loop (done)
  778.             (if (pending)
  779.                 (fixit)
  780.               (setq done t)))
  781.  
  782.      In this special form, the arguments FROM and TO are optional, but
  783.      must both be present or both absent.  If they are present, INC may
  784.      optionally be specified as well.  These arguments are grouped with
  785.      the argument VAR into a list, to distinguish them from BODY, which
  786.      includes all remaining elements of the form.
  787.  
  788. 
  789. File: lispref.info,  Node: A Sample Variable Description,  Prev: A Sample Function Description,  Up: Format of Descriptions
  790.  
  791. A Sample Variable Description
  792. .............................
  793.  
  794.    A "variable" is a name that can hold a value.  Although any variable
  795. can be set by the user, certain variables that exist specifically so
  796. that users can change them are called "user options".  Ordinary
  797. variables and user options are described using a format like that for
  798. functions except that there are no arguments.
  799.  
  800.    Here is a description of the imaginary `electric-future-map'
  801. variable.
  802.  
  803.  - Variable: electric-future-map
  804.      The value of this variable is a full keymap used by Electric
  805.      Command Future mode.  The functions in this map allow you to edit
  806.      commands you have not yet thought about executing.
  807.  
  808.    User option descriptions have the same format, but `Variable' is
  809. replaced by `User Option'.
  810.  
  811. 
  812. File: lispref.info,  Node: Acknowledgements,  Prev: Conventions,  Up: Introduction
  813.  
  814. Acknowledgements
  815. ================
  816.  
  817.    This manual was based on the GNU Emacs Lisp Reference Manual, version
  818. 2.4, written by Robert Krawitz, Bil Lewis, Dan LaLiberte, Richard M.
  819. Stallman and Chris Welty, the volunteers of the GNU manual group, in an
  820. effort extending over several years.  Robert J. Chassell helped to
  821. review and edit the manual, with the support of the Defense Advanced
  822. Research Projects Agency, ARPA Order 6082, arranged by Warren A. Hunt,
  823. Jr. of Computational Logic, Inc.
  824.  
  825.    Ben Wing adapted this manual for XEmacs 19.13, and earlier for Lucid
  826. Emacs 19.10 and XEmacs 19.12.  He is the sole author of many of the
  827. manual sections, in particular the XEmacs-specific sections: extents,
  828. glyphs, specifiers, toolbar, menubars, scrollbars, dialog boxes,
  829. devices, and others.  The section on annotations was originally written
  830. by Chuck Thompson.
  831.  
  832.    Corrections to the original GNU Emacs Lisp Reference Manual were
  833. supplied by Karl Berry, Jim Blandy, Bard Bloom, Stephane Boucher, David
  834. Boyes, Alan Carroll, Richard Davis, Lawrence R. Dodd, Peter Doornbosch,
  835. David A. Duff, Chris Eich, Beverly Erlebacher, David Eckelkamp, Ralf
  836. Fassel, Eirik Fuller, Stephen Gildea, Bob Glickstein, Eric Hanchrow,
  837. George Hartzell, Nathan Hess, Masayuki Ida, Dan Jacobson, Jak Kirman,
  838. Bob Knighten, Frederick M. Korz, Joe Lammens, Glenn M. Lewis, K. Richard
  839. Magill, Brian Marick, Roland McGrath, Skip Montanaro, John Gardiner
  840. Myers, Thomas A. Peterson, Francesco Potorti, Friedrich Pukelsheim,
  841. Arnold D. Robbins, Raul Rockwell, Per Starback, Shinichirou Sugou, Kimmo
  842. Suominen, Edward Tharp, Bill Trost, Rickard Westman, Jean White, Matthew
  843. Wilding, Carl Witty, Dale Worley, Rusty Wright, and David D. Zuhn.
  844.  
  845. 
  846. File: lispref.info,  Node: Lisp Data Types,  Next: Numbers,  Prev: Introduction,  Up: Top
  847.  
  848. Lisp Data Types
  849. ***************
  850.  
  851.    A Lisp "object" is a piece of data used and manipulated by Lisp
  852. programs.  For our purposes, a "type" or "data type" is a set of
  853. possible objects.
  854.  
  855.    Every object belongs to at least one type.  Objects of the same type
  856. have similar structures and may usually be used in the same contexts.
  857. Types can overlap, and objects can belong to two or more types.
  858. Consequently, we can ask whether an object belongs to a particular type,
  859. but not for "the" type of an object.
  860.  
  861.    A few fundamental object types are built into XEmacs.  These, from
  862. which all other types are constructed, are called "primitive types".
  863. Each object belongs to one and only one primitive type.  These types
  864. include "integer", "float", "cons", "symbol", "string", "vector",
  865. "subr", "byte-code function", and several special types, such as
  866. "buffer", that are related to editing.  (*Note Editing Types::.)
  867.  
  868.    Each primitive type has a corresponding Lisp function that checks
  869. whether an object is a member of that type.
  870.  
  871.    Note that Lisp is unlike many other languages in that Lisp objects
  872. are "self-typing": the primitive type of the object is implicit in the
  873. object itself.  For example, if an object is a vector, nothing can treat
  874. it as a number; Lisp knows it is a vector, not a number.
  875.  
  876.    In most languages, the programmer must declare the data type of each
  877. variable, and the type is known by the compiler but not represented in
  878. the data.  Such type declarations do not exist in Emacs Lisp.  A Lisp
  879. variable can have any type of value, and it remembers whatever value
  880. you store in it, type and all.
  881.  
  882.    This chapter describes the purpose, printed representation, and read
  883. syntax of each of the standard types in Emacs Lisp.  Details on how to
  884. use these types can be found in later chapters.
  885.  
  886. * Menu:
  887.  
  888. * Printed Representation::      How Lisp objects are represented as text.
  889. * Comments::                    Comments and their formatting conventions.
  890. * Programming Types::           Types found in all Lisp systems.
  891. * Editing Types::               Types specific to XEmacs.
  892. * Window-System Types::         Types specific to windowing systems.
  893. * Type Predicates::             Tests related to types.
  894. * Equality Predicates::         Tests of equality between any two objects.
  895.  
  896. 
  897. File: lispref.info,  Node: Printed Representation,  Next: Comments,  Up: Lisp Data Types
  898.  
  899. Printed Representation and Read Syntax
  900. ======================================
  901.  
  902.    The "printed representation" of an object is the format of the
  903. output generated by the Lisp printer (the function `prin1') for that
  904. object.  The "read syntax" of an object is the format of the input
  905. accepted by the Lisp reader (the function `read') for that object.
  906. Most objects have more than one possible read syntax.  Some types of
  907. object have no read syntax; except for these cases, the printed
  908. representation of an object is also a read syntax for it.
  909.  
  910.    In other languages, an expression is text; it has no other form.  In
  911. Lisp, an expression is primarily a Lisp object and only secondarily the
  912. text that is the object's read syntax.  Often there is no need to
  913. emphasize this distinction, but you must keep it in the back of your
  914. mind, or you will occasionally be very confused.
  915.  
  916.    Every type has a printed representation.  Some types have no read
  917. syntax, since it may not make sense to enter objects of these types
  918. directly in a Lisp program.  For example, the buffer type does not have
  919. a read syntax.  Objects of these types are printed in "hash notation":
  920. the characters `#<' followed by a descriptive string (typically the
  921. type name followed by the name of the object), and closed with a
  922. matching `>'.  Hash notation cannot be read at all, so the Lisp reader
  923. signals the error `invalid-read-syntax' whenever it encounters `#<'.
  924.  
  925.      (current-buffer)
  926.           => #<buffer objects.texi>
  927.  
  928.    When you evaluate an expression interactively, the Lisp interpreter
  929. first reads the textual representation of it, producing a Lisp object,
  930. and then evaluates that object (*note Evaluation::.).  However,
  931. evaluation and reading are separate activities.  Reading returns the
  932. Lisp object represented by the text that is read; the object may or may
  933. not be evaluated later.  *Note Input Functions::, for a description of
  934. `read', the basic function for reading objects.
  935.  
  936. 
  937. File: lispref.info,  Node: Comments,  Next: Programming Types,  Prev: Printed Representation,  Up: Lisp Data Types
  938.  
  939. Comments
  940. ========
  941.  
  942.    A "comment" is text that is written in a program only for the sake
  943. of humans that read the program, and that has no effect on the meaning
  944. of the program.  In Lisp, a semicolon (`;') starts a comment if it is
  945. not within a string or character constant.  The comment continues to
  946. the end of line.  The Lisp reader discards comments; they do not become
  947. part of the Lisp objects which represent the program within the Lisp
  948. system.
  949.  
  950.    The `#@COUNT' construct, which skips the next COUNT characters, is
  951. useful for program-generated comments containing binary data.  The
  952. Emacs Lisp byte compiler uses this in its output files (*note Byte
  953. Compilation::.).  It isn't meant for source files, however.
  954.  
  955.    *Note Comment Tips::, for conventions for formatting comments.
  956.  
  957. 
  958. File: lispref.info,  Node: Programming Types,  Next: Editing Types,  Prev: Comments,  Up: Lisp Data Types
  959.  
  960. Programming Types
  961. =================
  962.  
  963.    There are two general categories of types in Emacs Lisp: those having
  964. to do with Lisp programming, and those having to do with editing.  The
  965. former exist in many Lisp implementations, in one form or another.  The
  966. latter are unique to Emacs Lisp.
  967.  
  968. * Menu:
  969.  
  970. * Integer Type::        Numbers without fractional parts.
  971. * Floating Point Type:: Numbers with fractional parts and with a large range.
  972. * Character Type::      The representation of letters, numbers and
  973.                         control characters.
  974. * Symbol Type::         A multi-use object that refers to a function,
  975.                         variable, or property list, and has a unique identity.
  976. * Sequence Type::       Both lists and arrays are classified as sequences.
  977. * Cons Cell Type::      Cons cells, and lists (which are made from cons cells).
  978. * Array Type::          Arrays include strings and vectors.
  979. * String Type::         An (efficient) array of characters.
  980. * Vector Type::         One-dimensional arrays.
  981. * Function Type::       A piece of executable code you can call from elsewhere.
  982. * Macro Type::          A method of expanding an expression into another
  983.                           expression, more fundamental but less pretty.
  984. * Primitive Function Type::     A function written in C, callable from Lisp.
  985. * Byte-Code Type::      A function written in Lisp, then compiled.
  986. * Autoload Type::       A type used for automatically loading seldom-used
  987.                         functions.
  988.  
  989. 
  990. File: lispref.info,  Node: Integer Type,  Next: Floating Point Type,  Up: Programming Types
  991.  
  992. Integer Type
  993. ------------
  994.  
  995.    The range of values for integers in Emacs Lisp is -134217728 to
  996. 134217727 (28 bits; i.e.,
  997.  
  998.    -2**27 to
  999.  
  1000.    2**27 - 1) on most machines.  (Some machines may provide a wider
  1001. range.)  It is important to note that the Emacs Lisp arithmetic
  1002. functions do not check for overflow.  Thus `(1+ 134217727)' is
  1003. -134217728 on most machines.
  1004.  
  1005.    The read syntax for integers is a sequence of (base ten) digits with
  1006. an optional sign at the beginning and an optional period at the end.
  1007. The printed representation produced by the Lisp interpreter never has a
  1008. leading `+' or a final `.'.
  1009.  
  1010.      -1               ; The integer -1.
  1011.      1                ; The integer 1.
  1012.      1.               ; Also The integer 1.
  1013.      +1               ; Also the integer 1.
  1014.      268435457        ; Also the integer 1!
  1015.                       ;   (on a 28-bit implementation)
  1016.  
  1017.    *Note Numbers::, for more information.
  1018.  
  1019. 
  1020. File: lispref.info,  Node: Floating Point Type,  Next: Character Type,  Prev: Integer Type,  Up: Programming Types
  1021.  
  1022. Floating Point Type
  1023. -------------------
  1024.  
  1025.    XEmacs supports floating point numbers.  The precise range of
  1026. floating point numbers is machine-specific.
  1027.  
  1028.    The printed representation for floating point numbers requires either
  1029. a decimal point (with at least one digit following), an exponent, or
  1030. both.  For example, `1500.0', `15e2', `15.0e2', `1.5e3', and `.15e4'
  1031. are five ways of writing a floating point number whose value is 1500.
  1032. They are all equivalent.
  1033.  
  1034.    *Note Numbers::, for more information.
  1035.  
  1036.